package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.project.RCProject;
import com.shrct.businessprocess.project.RCProjectProcessEvent;
import com.shrct.businessprocess.project.RCProjectProcessEventStatus;
import com.shrct.businessprocess.project.impl.RCProjectEventImpl;
import com.shrct.businessprocess.project.proxy.RCProjectProcessEventProxy;
import edu.fudan.langlab.domain.workflow.BusinessProcess;
import edu.fudan.langlab.domain.workflow.impl.BusinessProcessImpl;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCPROJECTPROCESSEVENT_TYPE")
public class RCProjectProcessEventImpl extends RCProjectEventImpl implements RCProjectProcessEvent {
  public RCProjectProcessEventImpl() {
    super();
  }
  
  public RCProjectProcessEventImpl(final RCProject project) {
    super( project);
    
  }
  
  private RCProjectProcessEventStatus status;
  
  public RCProjectProcessEventStatus getStatus() {
    return this.status;
  }
  
  public RCProjectProcessEvent setStatus(final RCProjectProcessEventStatus status) {
    this.status = status;
    return this;			
    
  }
  
  private Date finishDate;
  
  public Date getFinishDate() {
    return this.finishDate;
  }
  
  public RCProjectProcessEvent setFinishDate(final Date finishDate) {
    this.finishDate = finishDate;
    return this;			
    
  }
  
  @JoinColumn(name = "bp_id")
  @ManyToOne(targetEntity = BusinessProcessImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private BusinessProcess bp;
  
  public BusinessProcess getBp() {
    return this.bp;
  }
  
  public RCProjectProcessEvent setBp(final BusinessProcess bp) {
    this.bp = bp;
    return this;			
    
  }
  
  public static RCProjectProcessEvent create(final RCProject project, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.project.RCProjectProcessEvent rCProjectProcessEvent = new com.shrct.businessprocess.project.impl.RCProjectProcessEventImpl(
    	project
    );
    objectFactory.create(rCProjectProcessEvent);
    return rCProjectProcessEvent;			
    
  }
  
  public static RCProjectProcessEvent createRCProjectProcessEventImpl(final RCProject project, final IObjectFactory objectFactory, final Procedure1<RCProjectProcessEvent> init) {
    com.shrct.businessprocess.project.RCProjectProcessEvent rCProjectProcessEvent = new com.shrct.businessprocess.project.impl.RCProjectProcessEventImpl(
    	project
    );
    objectFactory.create(rCProjectProcessEvent);
    init.apply(rCProjectProcessEvent);
    
    return rCProjectProcessEvent;			
    
  }
  
  public RCProjectProcessEventProxy toProxy() {
    com.shrct.businessprocess.project.proxy.RCProjectProcessEventProxy proxy = new com.shrct.businessprocess.project.proxy.RCProjectProcessEventProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
